import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    redirect: '/users/list'
  },
  {
    path: '/users',
    meta: { title: '账户与权限管理' },
    children: [
      {
        path: 'list',
        name: 'UserList',
        component: () => import('@/views/users/UserList.vue'),
        meta: { title: '用户列表' }
      },
      {
        path: 'add',
        name: 'UserAdd',
        component: () => import('@/views/users/UserAdd.vue'),
        meta: { title: '新增用户' }
      },
      {
        path: 'profile',
        name: 'UserProfile',
        component: () => import('@/views/users/UserProfile.vue'),
        meta: { title: '个人档案' }
      },
      {
        path: 'roles',
        name: 'RoleManage',
        component: () => import('@/views/users/RoleManage.vue'),
        meta: { title: '角色管理' }
      }
    ]
  },
  {
    path: '/authorization',
    meta: { title: '授权管理' },
    children: [
      {
        path: 'list',
        name: 'AuthList',
        component: () => import('@/views/authorization/AuthList.vue'),
        meta: { title: '授权列表' }
      },
      {
        path: 'certificates',
        name: 'CertificateList',
        component: () => import('@/views/authorization/CertificateList.vue'),
        meta: { title: '许可证书列表' }
      },
      {
        path: 'applications',
        name: 'ApplicationList',
        component: () => import('@/views/authorization/ApplicationList.vue'),
        meta: { title: '我的申请' }
      },
      {
        path: 'event-log',
        name: 'EventLog',
        component: () => import('@/views/authorization/EventLog.vue'),
        meta: { title: '事件日志' }
      }
    ]
  },
  {
    path: '/online',
    meta: { title: '在线操作' },
    children: [
      {
        path: 'activate',
        name: 'OnlineActivate',
        component: () => import('@/views/online/OnlineActivate.vue'),
        meta: { title: '在线激活' }
      },
      {
        path: 'transfer',
        name: 'DeviceTransfer',
        component: () => import('@/views/online/DeviceTransfer.vue'),
        meta: { title: '设备迁移' }
      },
      {
        path: 'revoke',
        name: 'AuthRevoke',
        component: () => import('@/views/online/AuthRevoke.vue'),
        meta: { title: '授权撤销' }
      },
      {
        path: 'renewal',
        name: 'AuthRenewal',
        component: () => import('@/views/online/AuthRenewal.vue'),
        meta: { title: '授权续期' }
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router

